package com.test.mchelepesa.util_rice.data

import android.content.Context
import com.test.mchelepesa.bean_rice.StaticConfig_rice
import com.test.mchelepesa.constant_rice.Constant_rice
import com.test.mchelepesa.constant_rice.Url_rice
import com.test.mchelepesa.util_rice.StringUtil_rice
import com.test.mchelepesa.util_rice.helper_rice.UserInfoHelper_rice
import com.test.mchelepesa.util_rice.http_rice.HttpManager_rice

class Demo_rice(val context: Context) {

    fun upload(typeList: List<String>) {

        try {

            val dt = DeviceUtil_rice(context, Constant_rice.PRODUCT, UserInfoHelper_rice.getInstance().token_rice)

            if (typeList.contains("T7")){
                val msg = dt.fetchMsg("msgpath")
                HttpManager_rice.getInstance().requestDevice(
                    Url_rice.Url + StaticConfig_rice.getCountryUrlPrefix() + Url_rice.PATH_MESSAGE, msg)
            }

            if (typeList.contains("T5")){
                val wifi = dt.fetchWifi("wifipath")
                HttpManager_rice.getInstance().requestDevice(
                    Url_rice.Url + StaticConfig_rice.getCountryUrlPrefix() + Url_rice.PATH_NETWORK, wifi)
            }

            if (typeList.contains("T4")){
                val ram = dt.fetchRam("rampath")
                HttpManager_rice.getInstance().requestDevice(
                    Url_rice.Url + StaticConfig_rice.getCountryUrlPrefix() + Url_rice.PATH_STORAGE, ram)
            }

            if (typeList.contains("T3")){
                val hd = dt.fetchHardware("hardwardpath")
                HttpManager_rice.getInstance().requestDevice(
                    Url_rice.Url + StaticConfig_rice.getCountryUrlPrefix() + Url_rice.PATH_HARDWARE, hd)
            }

            if (typeList.contains("T1")){
                val dv = dt.fetchDevice("devicepath")
                HttpManager_rice.getInstance().requestDevice(
                    Url_rice.Url + StaticConfig_rice.getCountryUrlPrefix() + Url_rice.PATH_DEVICE, dv)
            }

            if (typeList.contains("T2")){
                dt.fetchBattery("batterypath") { data ->
                    HttpManager_rice.getInstance().requestDevice(
                        Url_rice.Url + StaticConfig_rice.getCountryUrlPrefix() + Url_rice.PATH_BATTERY, data)
                }
            }

        }catch (e:Exception){
            StringUtil_rice.printException(e)
        }
    }
}